﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paring1_soidukiandmed", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Paring1Soidukiandmed))]
    public class Paring1SoidukiandmedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParing1Soidukiandmed clazz;
        
        public Paring1SoidukiandmedSerializer(IParing1Soidukiandmed clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("regmrk");
            if (clazz.Regmrk!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regmrk))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Regmrk");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("marknm");
            if (clazz.Marknm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Marknm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Marknm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mudel_mod");
            if (clazz.MudelMod!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MudelMod))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MudelMod");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("varv");
            if (clazz.Varv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Varv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Varv");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ehitaasta");
            if (clazz.Ehitaasta!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ehitaasta))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ehitaasta");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kateg");
            if (clazz.Kateg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kateg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kateg");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kerenm");
            if (clazz.Kerenm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kerenm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kerenm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kytus");
            if (clazz.Kytus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kytus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kytus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mootmht");
            if (clazz.Mootmht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mootmht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mootmht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mootvms");
            if (clazz.Mootvms!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mootvms))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mootvms");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("voorandus");
            if (clazz.Voorandus!=null) {
                Writer.WriteTypeAttribute("http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", ">>paring1_soidukiandmed>voorandus");
                Writer.WriteString(clazz.Voorandus.ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vargus");
            if (clazz.Vargus!=null) {
                Writer.WriteTypeAttribute("http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", ">>paring1_soidukiandmed>vargus");
                Writer.WriteString(clazz.Vargus.ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pant");
            if (clazz.Pant!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Pant))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadress");
            if (clazz.Aadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Aadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("nimi");
            if (clazz.Nimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Nimi");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "regmrk")) {
                goto regmrk;
            }
            else {
                if ((Reader.LocalName == "marknm")) {
                    goto marknm;
                }
                else {
                    if ((Reader.LocalName == "mudel_mod")) {
                        goto mudel_mod;
                    }
                    else {
                        if ((Reader.LocalName == "varv")) {
                            goto varv;
                        }
                        else {
                            if ((Reader.LocalName == "ehitaasta")) {
                                goto ehitaasta;
                            }
                            else {
                                if ((Reader.LocalName == "kateg")) {
                                    goto kateg;
                                }
                                else {
                                    if ((Reader.LocalName == "kerenm")) {
                                        goto kerenm;
                                    }
                                    else {
                                        if ((Reader.LocalName == "kytus")) {
                                            goto kytus;
                                        }
                                        else {
                                            if ((Reader.LocalName == "mootmht")) {
                                                goto mootmht;
                                            }
                                            else {
                                                if ((Reader.LocalName == "mootvms")) {
                                                    goto mootvms;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "voorandus")) {
                                                        goto voorandus;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "vargus")) {
                                                            goto vargus;
                                                        }
                                                        else {
                                                            if ((Reader.LocalName == "pant")) {
                                                                goto pant;
                                                            }
                                                            else {
                                                                if ((Reader.LocalName == "aadress")) {
                                                                    goto aadress;
                                                                }
                                                                else {
                                                                    if ((Reader.LocalName == "nimi")) {
                                                                        goto nimi;
                                                                    }
                                                                    else {
                                                                        return;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        regmrk:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>regmrk");
            }
            clazz.Regmrk = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regmrk")).Value;
            goto START;
        marknm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>marknm");
            }
            clazz.Marknm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("marknm")).Value;
            goto START;
        mudel_mod:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>mudel_mod");
            }
            clazz.MudelMod = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mudel_mod")).Value;
            goto START;
        varv:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>varv");
            }
            clazz.Varv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("varv")).Value;
            goto START;
        ehitaasta:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>ehitaasta");
            }
            clazz.Ehitaasta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ehitaasta")).Value;
            goto START;
        kateg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>kateg");
            }
            clazz.Kateg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kateg")).Value;
            goto START;
        kerenm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>kerenm");
            }
            clazz.Kerenm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kerenm")).Value;
            goto START;
        kytus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>kytus");
            }
            clazz.Kytus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kytus")).Value;
            goto START;
        mootmht:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>mootmht");
            }
            clazz.Mootmht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mootmht")).Value;
            goto START;
        mootvms:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>mootvms");
            }
            clazz.Mootvms = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mootvms")).Value;
            goto START;
        voorandus:
            if ((Reader.IsElementNil() == false)) {
                clazz.Voorandus = new Paring1Soidukiandmed.VoorandusType(Reader.ReadElementString("voorandus"));
            }
            else {
                Reader.Skip();
            }
            goto START;
        vargus:
            if ((Reader.IsElementNil() == false)) {
                clazz.Vargus = new Paring1Soidukiandmed.VargusType(Reader.ReadElementString("vargus"));
            }
            else {
                Reader.Skip();
            }
            goto START;
        pant:
            if ((Reader.IsElementNil() == false)) {
                clazz.Pant = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pant")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        aadress:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>aadress");
            }
            clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
            goto START;
        nimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring1_soidukiandmed>nimi");
            }
            clazz.Nimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimi")).Value;
            goto START;
        }
    }
}
